//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Reflection;
using OpenLS.Core.Notification;
using OpenLS.Core.Serialization;
using OpenLS.Drawing.Serialization;

namespace OpenLS.Drawing.Diagram
{
    class TextProperties :ViewModelBase, IOfficeXmlSerializable
    {
        private Shape3D _sp3d;
        private FlatText _flatText;
        internal const string xmlName = "txPr";
        public Shape3D Shape3D
        {
            get { return _sp3d; }
            set { _sp3d = value; notifyPropertyChanged("Shape3D"); }
        }
        public FlatText FlatText
        {
            get { return _flatText; }
            set { _flatText = value; notifyPropertyChanged("FlatText"); }
        }

        public void ReadXml(ReadContext context)
        {
            using (var c =context.ReadAndSwitch(xmlName, DrawingConstants.DrawingNamespaceUri, false))
            {
                Shape3D = c.ReadOptionalElement<Shape3D>("sp3d");
                if (Shape3D == null)
                    FlatText = c.ReadOptionalElement<FlatText>("flatTx");

            }
        }
        public void WriteXml(WriteContext context)
        {
            using (var c = context.WriteAndSwitch(xmlName, DrawingConstants.DrawingNamespace))
            {
                c.WriteOptionalElement(Shape3D );
                if (Shape3D == null)
                    c.WriteOptionalElement(FlatText );

            }
        }
    }
}